<%@page pageEncoding="UTF-8" contentType="text/html;charset=UTF-8"%>
<%@taglib prefix="shiro" uri="http://shiro.apache.org/tags"%>
<link href="${apliPath}static/css/default.css" rel="stylesheet"
	type="text/css" />
<link rel="stylesheet" type="text/css"
	href="${apliPath}static/js/themes/metro-solidBlue/easyui.css" />
<link rel="stylesheet" type="text/css"
	href="${apliPath}static/js/themes/icon.css" />
<script type="text/javascript"
	src="${apliPath}static/js/jquery-1.10.2.js"></script>
<script type="text/javascript"
	src="${apliPath}static/js/jquery.easyui.min.js"></script>
<script type="text/javascript"
	src="${apliPath}static/js/locale/easyui-lang-zh_CN.js"></script>
<script type="text/javascript" src="${apliPath}static/js/comet4j.js"></script>

<body class="easyui-layout">
	<input type="hidden" id='serverFlag' />
	<div data-options="region:'north',collapsible:false"
		style="height:90;border:0px;">
		<table width="90" border="0" cellpadding="0" cellspacing="0"
			style="font-size:12px;">
			<tr align="center">
				<td width="100"
					onclick="addTab('管理日志','${apliPath}cms/manageSysLog.jsp','icon-page-unlock')"><img
					src="${apliPath}static/images/calendar.png" /></td>
				<td width="80"
					onclick="addTab('热门专辑','${apliPath}cms/hotAlbum.jsp','icon-page-unlock')"><img
					src="${apliPath}static/images/clock.png" /></td>
				<shiro:hasPermission name='fun:announcement:add'>
					<td onclick="$('#announcementContent').dialog('open')" width="76"><img
						src="${apliPath}static/images/addBug.png" />
				</shiro:hasPermission>
				<td
					onclick="addTab('数据监控','${apliPath}druid/index.html','icon-page-unlock')"
					width="74"><img src="${apliPath}static/images/chart.png" /> <%-- 	
				<td width="76"><img src="${apliPath}static/images/addBug.png" /></td>
				<td width="76"><img src="${apliPath}static/images/log.png" /></td>
				<td width="81"><img src="${apliPath}static/images/log.png" /></td>
				<td width="71"><img src="${apliPath}static/images/log.png" /></td>
				<td width="95"><img src="${apliPath}static/images/users.png" /></td> --%>
			</tr>
			<tr align="center">
				<td>近期日志</td>
				<td>统计下载</td>
				<shiro:hasPermission name='fun:announcement:add'>
					<td>添加公告</td>
				</shiro:hasPermission>
				<td>数据监控</td>
				<!-- <td>巡检率统计</td>
				<td>缺陷录入</td>
				<td>班长日志</td>
				<td>值长日志</td>
				<td>检修日志</td>
				<td>系统用户及权限</td> -->
			</tr>
		</table>
	</div>
	<div data-options="region:'center'" style="border:0px;">
		<div class="easyui-layout" data-options="fit:true">
			<div data-options="region:'west',title:'缺陷留言',collapsible:false"
				style="width:400;border:1px;">
				<textarea id="suggestion" rows="20" cols="45">写在此处</textarea>
				<div style="margin:15 0 0 30">
					<a style="margin-right: 30" href="#"
						onclick="javascript:submitSuggestion()" class="easyui-linkbutton"
						data-options="iconCls:'icon-save'">保存</a> <a href="#"
						onclick="javascript:$('#suggestion').val('')"
						class="easyui-linkbutton" data-options="iconCls:'icon-clear'">清空</a>
				</div>
			</div>
			<div data-options="region:'center'"
				style="border:0px;background-color:#B8D2EB">
				<div class="easyui-layout" data-options="fit:true">
					<div data-options="region:'north',title:'近期登陆',collapsible:false"
						style="height:200;border:1px;">
						<table id="currentManagers">
						</table>
					</div>
					<div data-options="region:'center',title:'最近公告'" id="announceArea"
						style="border:1px;"></div>
				</div>
			</div>
		</div>
	</div>
	<div id="announcementContent" class="easyui-dialog"
		style="top: 40;width: 350;height: 280"
		data-options="closed:true,title:'发布公告',onClose: function(){
		            $('#announcementContentForm').form('reset');
				}">
		<form id="announcementContentForm" method="post"
			action="${apliPath}announcement/insertAnnouncement">
			<table style="margin: 20px" border="0" cellpadding="0"
				cellspacing="0">
				<tr>
					<td valign="top" style="padding: 0 6 10 0">公告主题:</td>
					<td><textarea name="title" cols="30" rows="8"></textarea></td>
				</tr>
				<tr height="50">
					<td align="middle">地址链接:</td>
					<td><input name="url" type="text" style="width: 180"
						width="180" /></td>
				</tr>
				<tr>
					<td align='middle' colspan="2"><a style="margin-right: 30"
						href="javascript:;"
						onclick="javascript:$('#announcementContentForm').form('submit');$('#announcementContent').dialog('close')"
						class="easyui-linkbutton" data-options="iconCls:'icon-save'">保存</a><a
						href="javascript:;"
						onclick="javascript:$('#announcementContent').dialog('close')"
						class="easyui-linkbutton" data-options="iconCls:'icon-clear'">算了</a></td>
				</tr>
			</table>
		</form>
	</div>
</body>
<script type="text/javascript">
	$(function() {
		loadCurrentManagersTables();
		loadAnnouncementArea();
        /*reServerMsg();
        setInterval(function() {
            $("#serverFlag").val("0");
            setTimeout(function() {
                var serverFlag = $("#serverFlag").val();
                if (serverFlag == "0") {//与服务器断开连接，重新连接服务器
                    JS.Engine.start('${apliPath}conn');
				}
			}, 2000);

		}, 3000);*/
	});
	function submitSuggestion() {
		$.messager.show({
			title : "提示框",
			msg : "感谢提醒",
		});
		$('#suggestion').val('');
	}
	function loadCurrentManagersTables() {
		$("#currentManagers").datagrid({
			fit : true,
			border : false,
			url : "${apliPath}home/currentManagers",
			loadMsg : "数据正在加载中，请稍等...",
			singleSelect : true,
			columns : [ [ {
				title : "登录账户",
				field : "code",
				width : 100,
				align : "center"
			}, {
				title : "登录时间",
				field : "loginTime",
				width : 180,
				align : "center"
			}, {
				title : "请求IP",
				field : "loginIP",
				width : 180,
				align : "center"
			} ] ],
		});
	}
	function addTab(subtitle, url, icon) {
		parent.addTab(subtitle, url, icon);
	}
	function loadAnnouncementArea() {
		$
				.post(
						"${apliPath}home/listAnnouncementByManager",
						function(data) {
							$
									.each(
											data,
											function(index, data) {
												$('#announceArea')
														.append(
																'<div style="margin:5 0 0 10"><a style="font-size: 14;color: blue;" target="_blank" href='+data.url+' >'
																		+ data.title
																		+ '</a></div>');
											});
						});
	}
	function reServerMsg() {
		JS.Engine.on({
			"announcementStatus" : function(kb) {//接收服务器时间
				if (kb == 'change') {
					$('#announceArea').html('');
					loadAnnouncementArea();
				}
			},
			"serverFlag" : function(flag) {//接收服务器状态
				$("#serverFlag").val(flag);
			}
		});
		JS.Engine.start('${apliPath}conn');
	}
</script>





